package com.metacube.questionbank.dao;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.metacube.questionbank.dto.QuestionDTO;
import com.metacube.questionbank.jdbc.QuestionRowMapper;

@Repository
public class RecentQuestionsDAO {
	@Autowired
	DataSource dataSource;
	public List<QuestionDTO> getRecentQuestions() {
		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		String query = "select * from question limit 5";
		return (jdbcTemplate.query(query, new QuestionRowMapper()));
	}
	
	/*public List<RecentQuestionDTO> getTopQuestions() {

		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		String query = "SELECT * from TopQuestions limit 5";
		return (jdbcTemplate.query(query, new RecentQuestionMapper()));
	}
	public List<RecentQuestionDTO> getUnansweredQuestions() {

		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		String query = "SELECT * from UnansweredQuestions limit 5";
		return (jdbcTemplate.query(query, new RecentQuestionMapper()));

}*/
}
